﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Wsitech.Model;
using Wsitech.BLL;

public partial class en_NewsCenter_Index : System.Web.UI.Page
{
    private string Press_Release_Id = TextInfoBLL.SITEMAPID_PRESS_RELEASE;
    private string Media_Reports_Id = TextInfoBLL.SITEMAPID_MEDIA_REPORT;
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            bindPressRelease();
            bindMediaReports();
        }
    }
    /// <summary>
    /// 绑定Press_Release
    /// </summary>
    /// <param name="Press_Release_Id"></param>
    private void bindPressRelease()
    {
        int count = 0;
        IList<TextInfo> list = TextInfoBLL.Instance.GetActivePagedListBySiteMapID(Press_Release_Id, AspNetPager1.CurrentPageIndex, AspNetPager1.PageSize, ref count);
        repPressRelease.DataSource = list;
        repPressRelease.DataBind();
        AspNetPager1.RecordCount = count;

    }

    /// <summary>
    /// 绑定MediaReport
    /// </summary>
    /// <param name="Media_Reports_Id"></param>
    private void bindMediaReports()
    {
        int count = 0;
        IList<TextInfo> list = TextInfoBLL.Instance.GetActivePagedListBySiteMapID(Media_Reports_Id, AspNetPager2.CurrentPageIndex, AspNetPager2.PageSize, ref count);
        repMediaReports.DataSource = list;
        repMediaReports.DataBind();
        AspNetPager2.RecordCount = count;
    }

    //换页
    protected void AspNetPager1_PageChanged(object sender, EventArgs e)
    {
        bindPressRelease();
    }
    protected void AspNetPager2_PageChanged(object sender, EventArgs e)
    {
        bindMediaReports();
    }


    protected string GetReportUrl(TextInfo info)
    {
        if (info != null)
        {
            if (info.ReferenceUrl != "")
            {
                return info.ReferenceUrl;
            }
            else
            {
                return string.Format("{0}?tid={1}", Wsitech.Utility.GlobalConst.REPORT_VIEW_EN, info.TextInfoId);
            }
        }
        return "";

        //return string.Format("{0}?tid={1}", Wsitech.Utility.GlobalConst.REPORT_VIEW_EN, info.TextInfoId);
    }
}